/**
 * Created by lijing on 2016-06-22.
 */
$.validator.setDefaults({
    submitHandler: function () {
        savePub();
    }
});
$(document).ready(function () {
    validate();
    $("#corpName").click(function () {
        $("#corpName").cate({
            title: "企业",
            url: G_Path.path + "/user/company/json",
            param: {"dictCode": ""},
            liveSearch: false,
            "id": "corpId",
            "name": "corpName"
        });
    });
});
function validate() {
    //设置默认属性
    $("#mainForm").validate({
        rules: {
            city: {
                required: true,
                minlength: 1
            },
            address: {
                required: true,
                minlength: 1
            }

        },
        messages: {
            city: {
                required: "请输入选择城市",
                minlength: ""
            },
            address: {
                required: "请输入地址",
                minlength: ""
            }
        }
    });
}
function savePub() {
    $.post(G_Path.path + "/user/ding/interface/save", $("#mainForm").serialize(), function (text) {
        var data = $.parseJSON(text);
        if (data.success) {
            if ("view" == status) {
                history.back();
            } else {
                window.close();
            }
        } else {
            showDialogMessage(data.msg);
        }
    });
}